#include "Configuration.h"
#include "DirScanner.h"
#include "FileProcessor.h"
#include "PageLib.h"
#include "WebPage.h"
/* #include "tinyxml2.h" */

int main() {
    Configuration& config = Configuration::getInstance("./config.txt");

    // 获取配置文件内容
    const std::map<std::string, std::string>& configMap = config.getConfigMap();
    for (const auto& pair : configMap) {
        std::cout << "Key: " << pair.first << ", Value: " << pair.second << std::endl;
    }

    // 获取停用词列表
    // const std::set<std::string>& stopWordList = config.getStopWordList();
    // for (const auto& word : stopWordList) {
    //     std::cout << "Stop Word: " << word << std::endl;
    // }
    // 处理异常

    DirScanner testdir;
    testdir();

    // const std::vector<std::string>& resdir = testdir.getfiles();
    // for (const auto& elem : resdir) {
    //     std::cout << elem << std::endl;
    // }

    // std::cout << "PageLib pageLib(testdir);之前" << std::endl;
    PageLib pageLib(testdir);        

    // std::cout << "FileProcessor fileProcessor(pageLib);之前" << std::endl;
    FileProcessor fileProcessor(pageLib);

    // std::cout << "fileProcessor.create();之前" << std::endl;
    fileProcessor.create();

    // pageLib.readInfoFormFiles();
    // map<int, pair<int, int>> testMap = pageLib.getOffsetLib();

    // for (auto &elem : testMap) {
    //     std::cout << elem.first << " " << elem.second.first << " " << elem.second.second << std::endl;
    // }
    
    vector<WebPage> testV = pageLib.getWebPage();

    for (auto& elem : testV ) {
        elem.WebPagePrint();
    }
    return 0;
}

